clear all

set more 1
set mat 800
set mem 150M
set logtype text

cd "C:\Data\PSID\Injury\RESTAT files"

capture log close

log using "KVWZ_94(1)_table7.txt",replace

use "C:\Data\PSID\Injury\Feb10\pandat_mar08.dta"

drop if lagfatal_==.
g lagfatal=lagfatal_

*****************************
*****************************
* identifying individuals in sample only once
*****************************

sort id

g one=1

by id: g vsum=sum(one)

tsset id year

by id: egen tempvar=max(vsum)

gen solo=1 if tempvar==1
replace solo=0 if tempvar~=1

drop tempvar



*****************************
*****************************



gen lnhours=log(ttl_work_hrs)

/* define panel id variables */

iis id
tis year

/* define year dummies and other vars for regression */

quietly tab year, gen(yr_)
g age2=age^2
quietly tab state_fips, gen(state)
quietly tab sic, gen(sic)

/* Census Divisions --- http://www.census.gov/geo/www/us_regdiv.pdf */
/* State FIPS Codes --- http://www.bls.gov/lau/lausfips.htm */

g cendiv=1 if state_fips==9 | state_fips==23 | state_fips==25 | state_fips==33 | state_fips==44 | state_fips==50
replace cendiv=2 if state_fips==34 | state_fips==36 | state_fips==42
replace cendiv=3 if state_fips==17 | state_fips==18 | state_fips==26 | state_fips==39 | state_fips==55
replace cendiv=4 if state_fips==19 | state_fips==20 | state_fips==27 | state_fips==29 | state_fips==31 | state_fips==38 | state_fips==46
replace cendiv=5 if state_fips==10 | state_fips==11 | state_fips==12 | state_fips==13 | state_fips==24 | state_fips==37 | state_fips==45 | state_fips==51 | state_fips==54
replace cendiv=6 if state_fips==1 | state_fips==21 | state_fips==28 | state_fips==47
replace cendiv=7 if state_fips==5 | state_fips==22 | state_fips==40 | state_fips==48
replace cendiv=8 if state_fips==4 | state_fips==8 | state_fips==16 | state_fips==30 | state_fips==32 | state_fips==35 | state_fips==49 | state_fips==56
replace cendiv=9 if state_fips==2 | state_fips==6 | state_fips==15 | state_fips==41 | state_fips==53
quietly tab cendiv, gen(cendiv)



/* 1-yr changes in fatality rate */

tsset id year
g pct_chng=100*(fatalrate_ - lagfatal_)/lagfatal_
g pct_chng3b=100*(fatalrate3b_ - lagfatal3b_)/lagfatal3b_



duplicates report id

/*                                           */
/* Table 7 Robustness Checks  */
/*                                           */


/* @@@@@@@@@@@ OLS First Differences @@@@@@@@@@@ */


/* @@@ */
/* @@@ BASELINE: controls for educ, age, age2, region, union, marry, white, state, year @@@ */
/* @@@ */

/* annual fatality models */
quietly{
g fatal=fatalrate_

tsset id year

g dwage=lnrwage-l2.lnrwage
g did=id-l2.id

g dfatal=fatal-l2.fatal
g deduc=educ-l2.educ
g dage=age-l2.age
g dage2=age2-l2.age2
g dneast=neast-l2.neast
g dncent=ncent-l2.ncent
g dwest=west-l2.west
g dunion=union-l2.union
g dmarry=marry-l2.marry
g dwhite=white-l2.white

g docc1=occ1-l2.occ1
g docc2=occ2-l2.occ2
g docc3=occ3-l2.occ3
g docc4=occ4-l2.occ4
g docc5=occ5-l2.occ5
g docc6=occ6-l2.occ6
g docc7=occ7-l2.occ7
g docc8=occ8-l2.occ8
g docc9=occ9-l2.occ9
g docc10=occ10-l2.occ10

g dindd1=indd1-l2.indd1
g dindd2=indd2-l2.indd2
g dindd3=indd3-l2.indd3
g dindd4=indd4-l2.indd4
g dindd5=indd5-l2.indd5
g dindd6=indd6-l2.indd6
g dindd7=indd7-l2.indd7
g dindd8=indd8-l2.indd8
g dindd9=indd9-l2.indd9
g dindd10=indd10-l2.indd10

g dcendiv1=cendiv1-l2.cendiv1
g dcendiv2=cendiv2-l2.cendiv2
g dcendiv3=cendiv3-l2.cendiv3
g dcendiv4=cendiv4-l2.cendiv4
g dcendiv5=cendiv5-l2.cendiv5
g dcendiv6=cendiv6-l2.cendiv6
g dcendiv7=cendiv7-l2.cendiv7
g dcendiv8=cendiv8-l2.cendiv8
g dcendiv9=cendiv9-l2.cendiv9

g dsic1=sic1-l2.sic1
g dsic2=sic2-l2.sic2
g dsic3=sic3-l2.sic3
g dsic4=sic4-l2.sic4
g dsic5=sic5-l2.sic5
g dsic6=sic6-l2.sic6
g dsic7=sic7-l2.sic7
g dsic8=sic8-l2.sic8
g dsic9=sic9-l2.sic9
g dsic10=sic10-l2.sic10
g dsic11=sic11-l2.sic11
g dsic12=sic12-l2.sic12
g dsic13=sic13-l2.sic13
g dsic14=sic14-l2.sic14
g dsic15=sic15-l2.sic15
g dsic16=sic16-l2.sic16
g dsic17=sic17-l2.sic17
g dsic18=sic18-l2.sic18
g dsic19=sic19-l2.sic19
g dsic20=sic20-l2.sic20
g dsic21=sic21-l2.sic21
g dsic22=sic22-l2.sic22
g dsic23=sic23-l2.sic23
g dsic24=sic24-l2.sic24
g dsic25=sic25-l2.sic25
g dsic26=sic26-l2.sic26
g dsic27=sic27-l2.sic27
g dsic28=sic28-l2.sic28
g dsic29=sic29-l2.sic29
g dsic30=sic30-l2.sic30
g dsic31=sic31-l2.sic31
g dsic32=sic32-l2.sic32
g dsic33=sic33-l2.sic33
g dsic34=sic34-l2.sic34
g dsic35=sic35-l2.sic35
g dsic36=sic36-l2.sic36
g dsic37=sic37-l2.sic37
g dsic38=sic38-l2.sic38
g dsic39=sic39-l2.sic39
g dsic40=sic40-l2.sic40
g dsic41=sic41-l2.sic41
g dsic42=sic42-l2.sic42
g dsic43=sic43-l2.sic43
g dsic44=sic44-l2.sic44
g dsic45=sic45-l2.sic45
g dsic46=sic46-l2.sic46
g dsic47=sic47-l2.sic47
g dsic48=sic48-l2.sic48
g dsic49=sic49-l2.sic49
g dsic50=sic50-l2.sic50
g dsic51=sic51-l2.sic51
g dsic52=sic52-l2.sic52
g dsic53=sic53-l2.sic53
g dsic54=sic54-l2.sic54
g dsic55=sic55-l2.sic55
g dsic56=sic56-l2.sic56
g dsic57=sic57-l2.sic57
g dsic58=sic58-l2.sic58
g dsic59=sic59-l2.sic59
g dsic60=sic60-l2.sic60
g dsic61=sic61-l2.sic61
g dsic62=sic62-l2.sic62
g dsic63=sic63-l2.sic63
g dsic64=sic64-l2.sic64
g dsic65=sic65-l2.sic65
g dsic66=sic66-l2.sic66

g dstate1=state1-l2.state1
g dstate2=state2-l2.state2
g dstate3=state3-l2.state3
g dstate4=state4-l2.state4
g dstate5=state5-l2.state5
g dstate6=state6-l2.state6
g dstate7=state7-l2.state7
g dstate8=state8-l2.state8
g dstate9=state9-l2.state9
g dstate10=state10-l2.state10
g dstate11=state11-l2.state11
g dstate12=state12-l2.state12
g dstate13=state13-l2.state13
g dstate14=state14-l2.state14
g dstate15=state15-l2.state15
g dstate16=state16-l2.state16
g dstate17=state17-l2.state17
g dstate18=state18-l2.state18
g dstate19=state19-l2.state19
g dstate20=state20-l2.state20
g dstate21=state21-l2.state21
g dstate22=state22-l2.state22
g dstate23=state23-l2.state23
g dstate24=state24-l2.state24
g dstate25=state25-l2.state25
g dstate26=state26-l2.state26
g dstate27=state27-l2.state27
g dstate28=state28-l2.state28
g dstate29=state29-l2.state29
g dstate30=state30-l2.state30
g dstate31=state31-l2.state31
g dstate32=state32-l2.state32
g dstate33=state33-l2.state33
g dstate34=state34-l2.state34
g dstate35=state35-l2.state35
g dstate36=state36-l2.state36
g dstate37=state37-l2.state37
g dstate38=state38-l2.state38
g dstate39=state39-l2.state39
g dstate40=state40-l2.state40
g dstate41=state41-l2.state41
g dstate42=state42-l2.state42
g dstate43=state43-l2.state43
g dstate44=state44-l2.state44
g dstate45=state45-l2.state45
g dstate46=state46-l2.state46
g dstate47=state47-l2.state47
g dstate48=state48-l2.state48
g dstate49=state49-l2.state49
g dstate50=state50-l2.state50
}

replace fatal=fatalrate_
replace dfatal=fatal-l2.fatal

global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry"

reg dwage $dxx yr_2-yr_5 dstate2-dstate50 if pct_chng>-75 & pct_chng<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)

}

/* ivl1 uses fixed hours = 2000; ivl1_alt uses sample hours */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf



/* 3-year fatality models (B) */

replace fatal=fatalrate3b_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry"

reg dwage $dxx yr_2-yr_5 dstate2-dstate50 if pct_chng3b>-75 & pct_chng3b<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* ivl1 uses fixed hours = 2000; ivl1_alt uses sample hours */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf

/* @@@ */
/* @@@ Robust1: adds controls for 1-digit occupation @@@ */
/* @@@ */

replace fatal=fatalrate_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry docc1-docc9"

reg dwage $dxx yr_2-yr_5 dstate2-dstate50 if pct_chng>-75 & pct_chng<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf



/* 3-year fatality models (B) */

replace fatal=fatalrate3b_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry docc1-docc9"

reg dwage $dxx yr_2-yr_5 dstate2-dstate50 if pct_chng3b>-75 & pct_chng3b<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf


/* @@@ */
/* @@@ Robust2: adds controls for 2-digit industry @@@ */
/* @@@ */

replace fatal=fatalrate_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry dsic2-dsic66"

reg dwage $dxx yr_2-yr_5 dstate2-dstate50 if pct_chng>-75 & pct_chng<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf



/* 3-year fatality models (B) */

replace fatal=fatalrate3b_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry dsic2-dsic66"

reg dwage $dxx yr_2-yr_5 dstate2-dstate50 if pct_chng3b>-75 & pct_chng3b<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf


/* @@@ */
/* @@@ Robust3: adds controls for 1-digit occ & 2-digit industry @@@ */
/* @@@ */

/* SEE ORIGINAL POOLED CROSS SECTION RESULTS */


/* @@@ */
/* @@@ Robust4: adds controls for 1-digit occ by year & 2-digit industry @@@ */
/* @@@ */

quietly{
g docc1_yr_1=docc1*yr_1
g docc2_yr_1=docc2*yr_1
g docc3_yr_1=docc3*yr_1
g docc4_yr_1=docc4*yr_1
g docc5_yr_1=docc5*yr_1
g docc6_yr_1=docc6*yr_1
g docc7_yr_1=docc7*yr_1
g docc8_yr_1=docc8*yr_1
g docc9_yr_1=docc9*yr_1
g docc10_yr_1=docc10*yr_1
g docc1_yr_2=docc1*yr_2
g docc2_yr_2=docc2*yr_2
g docc3_yr_2=docc3*yr_2
g docc4_yr_2=docc4*yr_2
g docc5_yr_2=docc5*yr_2
g docc6_yr_2=docc6*yr_2
g docc7_yr_2=docc7*yr_2
g docc8_yr_2=docc8*yr_2
g docc9_yr_2=docc9*yr_2
g docc10_yr_2=docc10*yr_2
g docc1_yr_3=docc1*yr_3
g docc2_yr_3=docc2*yr_3
g docc3_yr_3=docc3*yr_3
g docc4_yr_3=docc4*yr_3
g docc5_yr_3=docc5*yr_3
g docc6_yr_3=docc6*yr_3
g docc7_yr_3=docc7*yr_3
g docc8_yr_3=docc8*yr_3
g docc9_yr_3=docc9*yr_3
g docc10_yr_3=docc10*yr_3
g docc1_yr_4=docc1*yr_4
g docc2_yr_4=docc2*yr_4
g docc3_yr_4=docc3*yr_4
g docc4_yr_4=docc4*yr_4
g docc5_yr_4=docc5*yr_4
g docc6_yr_4=docc6*yr_4
g docc7_yr_4=docc7*yr_4
g docc8_yr_4=docc8*yr_4
g docc9_yr_4=docc9*yr_4
g docc10_yr_4=docc10*yr_4
g docc1_yr_5=docc1*yr_5
g docc2_yr_5=docc2*yr_5
g docc3_yr_5=docc3*yr_5
g docc4_yr_5=docc4*yr_5
g docc5_yr_5=docc5*yr_5
g docc6_yr_5=docc6*yr_5
g docc7_yr_5=docc7*yr_5
g docc8_yr_5=docc8*yr_5
g docc9_yr_5=docc9*yr_5
g docc10_yr_5=docc10*yr_5
}

replace fatal=fatalrate_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry"

reg dwage $dxx yr_2-yr_5 docc2_yr_1-docc10_yr_5 dsic2-dsic66 dstate2-dstate50 if pct_chng>-75 & pct_chng<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)

}
/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf



/* 3-year fatality models (B) */

replace fatal=fatalrate3b_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry"

reg dwage $dxx yr_2-yr_5 docc2_yr_1-docc10_yr_5 dsic2-dsic66 dstate2-dstate50 if pct_chng3b>-75 & pct_chng3b<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf


/* @@@ */
/* @@@ Robust5: adds controls for 1-digit occ & 2-digit industry by year @@@ */
/* @@@ */

quietly{
g dsic2_yr_1=dsic2*yr_1
g dsic3_yr_1=dsic3*yr_1
g dsic4_yr_1=dsic4*yr_1
g dsic5_yr_1=dsic5*yr_1
g dsic6_yr_1=dsic6*yr_1
g dsic7_yr_1=dsic7*yr_1
g dsic8_yr_1=dsic8*yr_1
g dsic9_yr_1=dsic9*yr_1
g dsic10_yr_1=dsic10*yr_1
g dsic11_yr_1=dsic11*yr_1
g dsic12_yr_1=dsic12*yr_1
g dsic13_yr_1=dsic13*yr_1
g dsic14_yr_1=dsic14*yr_1
g dsic15_yr_1=dsic15*yr_1
g dsic16_yr_1=dsic16*yr_1
g dsic17_yr_1=dsic17*yr_1
g dsic18_yr_1=dsic18*yr_1
g dsic19_yr_1=dsic19*yr_1
g dsic20_yr_1=dsic20*yr_1
g dsic21_yr_1=dsic21*yr_1
g dsic22_yr_1=dsic22*yr_1
g dsic23_yr_1=dsic23*yr_1
g dsic24_yr_1=dsic24*yr_1
g dsic25_yr_1=dsic25*yr_1
g dsic26_yr_1=dsic26*yr_1
g dsic27_yr_1=dsic27*yr_1
g dsic28_yr_1=dsic28*yr_1
g dsic29_yr_1=dsic29*yr_1
g dsic30_yr_1=dsic30*yr_1
g dsic31_yr_1=dsic31*yr_1
g dsic32_yr_1=dsic32*yr_1
g dsic33_yr_1=dsic33*yr_1
g dsic34_yr_1=dsic34*yr_1
g dsic35_yr_1=dsic35*yr_1
g dsic36_yr_1=dsic36*yr_1
g dsic37_yr_1=dsic37*yr_1
g dsic38_yr_1=dsic38*yr_1
g dsic39_yr_1=dsic39*yr_1
g dsic40_yr_1=dsic40*yr_1
g dsic41_yr_1=dsic41*yr_1
g dsic42_yr_1=dsic42*yr_1
g dsic43_yr_1=dsic43*yr_1
g dsic44_yr_1=dsic44*yr_1
g dsic45_yr_1=dsic45*yr_1
g dsic46_yr_1=dsic46*yr_1
g dsic47_yr_1=dsic47*yr_1
g dsic48_yr_1=dsic48*yr_1
g dsic49_yr_1=dsic49*yr_1
g dsic50_yr_1=dsic50*yr_1
g dsic51_yr_1=dsic51*yr_1
g dsic52_yr_1=dsic52*yr_1
g dsic53_yr_1=dsic53*yr_1
g dsic54_yr_1=dsic54*yr_1
g dsic55_yr_1=dsic55*yr_1
g dsic56_yr_1=dsic56*yr_1
g dsic57_yr_1=dsic57*yr_1
g dsic58_yr_1=dsic58*yr_1
g dsic59_yr_1=dsic59*yr_1
g dsic60_yr_1=dsic60*yr_1
g dsic61_yr_1=dsic61*yr_1
g dsic62_yr_1=dsic62*yr_1
g dsic63_yr_1=dsic63*yr_1
g dsic64_yr_1=dsic64*yr_1
g dsic65_yr_1=dsic65*yr_1
g dsic66_yr_1=dsic66*yr_1
g dsic2_yr_2=dsic2*yr_2
g dsic3_yr_2=dsic3*yr_2
g dsic4_yr_2=dsic4*yr_2
g dsic5_yr_2=dsic5*yr_2
g dsic6_yr_2=dsic6*yr_2
g dsic7_yr_2=dsic7*yr_2
g dsic8_yr_2=dsic8*yr_2
g dsic9_yr_2=dsic9*yr_2
g dsic10_yr_2=dsic10*yr_2
g dsic11_yr_2=dsic11*yr_2
g dsic12_yr_2=dsic12*yr_2
g dsic13_yr_2=dsic13*yr_2
g dsic14_yr_2=dsic14*yr_2
g dsic15_yr_2=dsic15*yr_2
g dsic16_yr_2=dsic16*yr_2
g dsic17_yr_2=dsic17*yr_2
g dsic18_yr_2=dsic18*yr_2
g dsic19_yr_2=dsic19*yr_2
g dsic20_yr_2=dsic20*yr_2
g dsic21_yr_2=dsic21*yr_2
g dsic22_yr_2=dsic22*yr_2
g dsic23_yr_2=dsic23*yr_2
g dsic24_yr_2=dsic24*yr_2
g dsic25_yr_2=dsic25*yr_2
g dsic26_yr_2=dsic26*yr_2
g dsic27_yr_2=dsic27*yr_2
g dsic28_yr_2=dsic28*yr_2
g dsic29_yr_2=dsic29*yr_2
g dsic30_yr_2=dsic30*yr_2
g dsic31_yr_2=dsic31*yr_2
g dsic32_yr_2=dsic32*yr_2
g dsic33_yr_2=dsic33*yr_2
g dsic34_yr_2=dsic34*yr_2
g dsic35_yr_2=dsic35*yr_2
g dsic36_yr_2=dsic36*yr_2
g dsic37_yr_2=dsic37*yr_2
g dsic38_yr_2=dsic38*yr_2
g dsic39_yr_2=dsic39*yr_2
g dsic40_yr_2=dsic40*yr_2
g dsic41_yr_2=dsic41*yr_2
g dsic42_yr_2=dsic42*yr_2
g dsic43_yr_2=dsic43*yr_2
g dsic44_yr_2=dsic44*yr_2
g dsic45_yr_2=dsic45*yr_2
g dsic46_yr_2=dsic46*yr_2
g dsic47_yr_2=dsic47*yr_2
g dsic48_yr_2=dsic48*yr_2
g dsic49_yr_2=dsic49*yr_2
g dsic50_yr_2=dsic50*yr_2
g dsic51_yr_2=dsic51*yr_2
g dsic52_yr_2=dsic52*yr_2
g dsic53_yr_2=dsic53*yr_2
g dsic54_yr_2=dsic54*yr_2
g dsic55_yr_2=dsic55*yr_2
g dsic56_yr_2=dsic56*yr_2
g dsic57_yr_2=dsic57*yr_2
g dsic58_yr_2=dsic58*yr_2
g dsic59_yr_2=dsic59*yr_2
g dsic60_yr_2=dsic60*yr_2
g dsic61_yr_2=dsic61*yr_2
g dsic62_yr_2=dsic62*yr_2
g dsic63_yr_2=dsic63*yr_2
g dsic64_yr_2=dsic64*yr_2
g dsic65_yr_2=dsic65*yr_2
g dsic66_yr_2=dsic66*yr_2
g dsic2_yr_3=dsic2*yr_3
g dsic3_yr_3=dsic3*yr_3
g dsic4_yr_3=dsic4*yr_3
g dsic5_yr_3=dsic5*yr_3
g dsic6_yr_3=dsic6*yr_3
g dsic7_yr_3=dsic7*yr_3
g dsic8_yr_3=dsic8*yr_3
g dsic9_yr_3=dsic9*yr_3
g dsic10_yr_3=dsic10*yr_3
g dsic11_yr_3=dsic11*yr_3
g dsic12_yr_3=dsic12*yr_3
g dsic13_yr_3=dsic13*yr_3
g dsic14_yr_3=dsic14*yr_3
g dsic15_yr_3=dsic15*yr_3
g dsic16_yr_3=dsic16*yr_3
g dsic17_yr_3=dsic17*yr_3
g dsic18_yr_3=dsic18*yr_3
g dsic19_yr_3=dsic19*yr_3
g dsic20_yr_3=dsic20*yr_3
g dsic21_yr_3=dsic21*yr_3
g dsic22_yr_3=dsic22*yr_3
g dsic23_yr_3=dsic23*yr_3
g dsic24_yr_3=dsic24*yr_3
g dsic25_yr_3=dsic25*yr_3
g dsic26_yr_3=dsic26*yr_3
g dsic27_yr_3=dsic27*yr_3
g dsic28_yr_3=dsic28*yr_3
g dsic29_yr_3=dsic29*yr_3
g dsic30_yr_3=dsic30*yr_3
g dsic31_yr_3=dsic31*yr_3
g dsic32_yr_3=dsic32*yr_3
g dsic33_yr_3=dsic33*yr_3
g dsic34_yr_3=dsic34*yr_3
g dsic35_yr_3=dsic35*yr_3
g dsic36_yr_3=dsic36*yr_3
g dsic37_yr_3=dsic37*yr_3
g dsic38_yr_3=dsic38*yr_3
g dsic39_yr_3=dsic39*yr_3
g dsic40_yr_3=dsic40*yr_3
g dsic41_yr_3=dsic41*yr_3
g dsic42_yr_3=dsic42*yr_3
g dsic43_yr_3=dsic43*yr_3
g dsic44_yr_3=dsic44*yr_3
g dsic45_yr_3=dsic45*yr_3
g dsic46_yr_3=dsic46*yr_3
g dsic47_yr_3=dsic47*yr_3
g dsic48_yr_3=dsic48*yr_3
g dsic49_yr_3=dsic49*yr_3
g dsic50_yr_3=dsic50*yr_3
g dsic51_yr_3=dsic51*yr_3
g dsic52_yr_3=dsic52*yr_3
g dsic53_yr_3=dsic53*yr_3
g dsic54_yr_3=dsic54*yr_3
g dsic55_yr_3=dsic55*yr_3
g dsic56_yr_3=dsic56*yr_3
g dsic57_yr_3=dsic57*yr_3
g dsic58_yr_3=dsic58*yr_3
g dsic59_yr_3=dsic59*yr_3
g dsic60_yr_3=dsic60*yr_3
g dsic61_yr_3=dsic61*yr_3
g dsic62_yr_3=dsic62*yr_3
g dsic63_yr_3=dsic63*yr_3
g dsic64_yr_3=dsic64*yr_3
g dsic65_yr_3=dsic65*yr_3
g dsic66_yr_3=dsic66*yr_3
g dsic2_yr_4=dsic2*yr_4
g dsic3_yr_4=dsic3*yr_4
g dsic4_yr_4=dsic4*yr_4
g dsic5_yr_4=dsic5*yr_4
g dsic6_yr_4=dsic6*yr_4
g dsic7_yr_4=dsic7*yr_4
g dsic8_yr_4=dsic8*yr_4
g dsic9_yr_4=dsic9*yr_4
g dsic10_yr_4=dsic10*yr_4
g dsic11_yr_4=dsic11*yr_4
g dsic12_yr_4=dsic12*yr_4
g dsic13_yr_4=dsic13*yr_4
g dsic14_yr_4=dsic14*yr_4
g dsic15_yr_4=dsic15*yr_4
g dsic16_yr_4=dsic16*yr_4
g dsic17_yr_4=dsic17*yr_4
g dsic18_yr_4=dsic18*yr_4
g dsic19_yr_4=dsic19*yr_4
g dsic20_yr_4=dsic20*yr_4
g dsic21_yr_4=dsic21*yr_4
g dsic22_yr_4=dsic22*yr_4
g dsic23_yr_4=dsic23*yr_4
g dsic24_yr_4=dsic24*yr_4
g dsic25_yr_4=dsic25*yr_4
g dsic26_yr_4=dsic26*yr_4
g dsic27_yr_4=dsic27*yr_4
g dsic28_yr_4=dsic28*yr_4
g dsic29_yr_4=dsic29*yr_4
g dsic30_yr_4=dsic30*yr_4
g dsic31_yr_4=dsic31*yr_4
g dsic32_yr_4=dsic32*yr_4
g dsic33_yr_4=dsic33*yr_4
g dsic34_yr_4=dsic34*yr_4
g dsic35_yr_4=dsic35*yr_4
g dsic36_yr_4=dsic36*yr_4
g dsic37_yr_4=dsic37*yr_4
g dsic38_yr_4=dsic38*yr_4
g dsic39_yr_4=dsic39*yr_4
g dsic40_yr_4=dsic40*yr_4
g dsic41_yr_4=dsic41*yr_4
g dsic42_yr_4=dsic42*yr_4
g dsic43_yr_4=dsic43*yr_4
g dsic44_yr_4=dsic44*yr_4
g dsic45_yr_4=dsic45*yr_4
g dsic46_yr_4=dsic46*yr_4
g dsic47_yr_4=dsic47*yr_4
g dsic48_yr_4=dsic48*yr_4
g dsic49_yr_4=dsic49*yr_4
g dsic50_yr_4=dsic50*yr_4
g dsic51_yr_4=dsic51*yr_4
g dsic52_yr_4=dsic52*yr_4
g dsic53_yr_4=dsic53*yr_4
g dsic54_yr_4=dsic54*yr_4
g dsic55_yr_4=dsic55*yr_4
g dsic56_yr_4=dsic56*yr_4
g dsic57_yr_4=dsic57*yr_4
g dsic58_yr_4=dsic58*yr_4
g dsic59_yr_4=dsic59*yr_4
g dsic60_yr_4=dsic60*yr_4
g dsic61_yr_4=dsic61*yr_4
g dsic62_yr_4=dsic62*yr_4
g dsic63_yr_4=dsic63*yr_4
g dsic64_yr_4=dsic64*yr_4
g dsic65_yr_4=dsic65*yr_4
g dsic66_yr_4=dsic66*yr_4
g dsic2_yr_5=dsic2*yr_5
g dsic3_yr_5=dsic3*yr_5
g dsic4_yr_5=dsic4*yr_5
g dsic5_yr_5=dsic5*yr_5
g dsic6_yr_5=dsic6*yr_5
g dsic7_yr_5=dsic7*yr_5
g dsic8_yr_5=dsic8*yr_5
g dsic9_yr_5=dsic9*yr_5
g dsic10_yr_5=dsic10*yr_5
g dsic11_yr_5=dsic11*yr_5
g dsic12_yr_5=dsic12*yr_5
g dsic13_yr_5=dsic13*yr_5
g dsic14_yr_5=dsic14*yr_5
g dsic15_yr_5=dsic15*yr_5
g dsic16_yr_5=dsic16*yr_5
g dsic17_yr_5=dsic17*yr_5
g dsic18_yr_5=dsic18*yr_5
g dsic19_yr_5=dsic19*yr_5
g dsic20_yr_5=dsic20*yr_5
g dsic21_yr_5=dsic21*yr_5
g dsic22_yr_5=dsic22*yr_5
g dsic23_yr_5=dsic23*yr_5
g dsic24_yr_5=dsic24*yr_5
g dsic25_yr_5=dsic25*yr_5
g dsic26_yr_5=dsic26*yr_5
g dsic27_yr_5=dsic27*yr_5
g dsic28_yr_5=dsic28*yr_5
g dsic29_yr_5=dsic29*yr_5
g dsic30_yr_5=dsic30*yr_5
g dsic31_yr_5=dsic31*yr_5
g dsic32_yr_5=dsic32*yr_5
g dsic33_yr_5=dsic33*yr_5
g dsic34_yr_5=dsic34*yr_5
g dsic35_yr_5=dsic35*yr_5
g dsic36_yr_5=dsic36*yr_5
g dsic37_yr_5=dsic37*yr_5
g dsic38_yr_5=dsic38*yr_5
g dsic39_yr_5=dsic39*yr_5
g dsic40_yr_5=dsic40*yr_5
g dsic41_yr_5=dsic41*yr_5
g dsic42_yr_5=dsic42*yr_5
g dsic43_yr_5=dsic43*yr_5
g dsic44_yr_5=dsic44*yr_5
g dsic45_yr_5=dsic45*yr_5
g dsic46_yr_5=dsic46*yr_5
g dsic47_yr_5=dsic47*yr_5
g dsic48_yr_5=dsic48*yr_5
g dsic49_yr_5=dsic49*yr_5
g dsic50_yr_5=dsic50*yr_5
g dsic51_yr_5=dsic51*yr_5
g dsic52_yr_5=dsic52*yr_5
g dsic53_yr_5=dsic53*yr_5
g dsic54_yr_5=dsic54*yr_5
g dsic55_yr_5=dsic55*yr_5
g dsic56_yr_5=dsic56*yr_5
g dsic57_yr_5=dsic57*yr_5
g dsic58_yr_5=dsic58*yr_5
g dsic59_yr_5=dsic59*yr_5
g dsic60_yr_5=dsic60*yr_5
g dsic61_yr_5=dsic61*yr_5
g dsic62_yr_5=dsic62*yr_5
g dsic63_yr_5=dsic63*yr_5
g dsic64_yr_5=dsic64*yr_5
g dsic65_yr_5=dsic65*yr_5
g dsic66_yr_5=dsic66*yr_5
}


replace fatal=fatalrate_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry docc1-docc9"

reg dwage $dxx yr_2-yr_5 dsic2_yr_1-dsic66_yr_5 dstate2-dstate50 if pct_chng>-75 & pct_chng<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf



/* 3-year fatality models (B) */

replace fatal=fatalrate3b_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry docc1-docc9"

reg dwage $dxx yr_2-yr_5 dsic2_yr_1-dsic66_yr_5 dstate2-dstate50 if pct_chng3b>-75 & pct_chng3b<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf


/* @@@ */
/* @@@ Robust6: adds controls for 1-digit occ & 2-digit industry & census division (remove regions) @@@ */
/* @@@ */

replace fatal=fatalrate_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dunion dmarry"

reg dwage $dxx yr_2-yr_5 docc1-docc9 dsic2-dsic66 dcendiv2-dcendiv9 dstate2-dstate50 if pct_chng>-75 & pct_chng<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf



/* 3-year fatality models (B) */

replace fatal=fatalrate3b_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dunion dmarry"

reg dwage $dxx yr_2-yr_5 docc1-docc9 dsic2-dsic66 dcendiv2-dcendiv9 dstate2-dstate50 if pct_chng3b>-75 & pct_chng3b<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)

}

/* Assume regressors are fixed constants in calculation of C.I. */

g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf


/* @@@ */
/* @@@ Robust7: adds controls for  census division by year @@@ */
/* @@@ */

quietly{
g dcendiv1_yr_1=dcendiv1*yr_1
g dcendiv2_yr_1=dcendiv2*yr_1
g dcendiv3_yr_1=dcendiv3*yr_1
g dcendiv4_yr_1=dcendiv4*yr_1
g dcendiv5_yr_1=dcendiv5*yr_1
g dcendiv6_yr_1=dcendiv6*yr_1
g dcendiv7_yr_1=dcendiv7*yr_1
g dcendiv8_yr_1=dcendiv8*yr_1
g dcendiv9_yr_1=dcendiv9*yr_1
g dcendiv1_yr_2=dcendiv1*yr_2
g dcendiv2_yr_2=dcendiv2*yr_2
g dcendiv3_yr_2=dcendiv3*yr_2
g dcendiv4_yr_2=dcendiv4*yr_2
g dcendiv5_yr_2=dcendiv5*yr_2
g dcendiv6_yr_2=dcendiv6*yr_2
g dcendiv7_yr_2=dcendiv7*yr_2
g dcendiv8_yr_2=dcendiv8*yr_2
g dcendiv9_yr_2=dcendiv9*yr_2
g dcendiv1_yr_3=dcendiv1*yr_3
g dcendiv2_yr_3=dcendiv2*yr_3
g dcendiv3_yr_3=dcendiv3*yr_3
g dcendiv4_yr_3=dcendiv4*yr_3
g dcendiv5_yr_3=dcendiv5*yr_3
g dcendiv6_yr_3=dcendiv6*yr_3
g dcendiv7_yr_3=dcendiv7*yr_3
g dcendiv8_yr_3=dcendiv8*yr_3
g dcendiv9_yr_3=dcendiv9*yr_3
g dcendiv1_yr_4=dcendiv1*yr_4
g dcendiv2_yr_4=dcendiv2*yr_4
g dcendiv3_yr_4=dcendiv3*yr_4
g dcendiv4_yr_4=dcendiv4*yr_4
g dcendiv5_yr_4=dcendiv5*yr_4
g dcendiv6_yr_4=dcendiv6*yr_4
g dcendiv7_yr_4=dcendiv7*yr_4
g dcendiv8_yr_4=dcendiv8*yr_4
g dcendiv9_yr_4=dcendiv9*yr_4
g dcendiv1_yr_5=dcendiv1*yr_5
g dcendiv2_yr_5=dcendiv2*yr_5
g dcendiv3_yr_5=dcendiv3*yr_5
g dcendiv4_yr_5=dcendiv4*yr_5
g dcendiv5_yr_5=dcendiv5*yr_5
g dcendiv6_yr_5=dcendiv6*yr_5
g dcendiv7_yr_5=dcendiv7*yr_5
g dcendiv8_yr_5=dcendiv8*yr_5
g dcendiv9_yr_5=dcendiv9*yr_5
}


replace fatal=fatalrate_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dunion dmarry"

reg dwage $dxx yr_2-yr_5 dcendiv1_yr_1-dcendiv9_yr_5 dstate2-dstate50 if pct_chng>-75 & pct_chng<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)

}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf



/* 3-year fatality models (B) */

replace fatal=fatalrate3b_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dunion dmarry"

reg dwage $dxx yr_2-yr_5 dcendiv1_yr_1-dcendiv9_yr_5 dstate2-dstate50 if pct_chng3b>-75 & pct_chng3b<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf


/* @@@ */
/* @@@ Robust8: adds controls for 1-digit occ, 2-digit ind, and state by year @@@ */
/* @@@ */


quietly{
g dstate1_yr_1=dstate1*yr_1
g dstate2_yr_1=dstate2*yr_1
g dstate3_yr_1=dstate3*yr_1
g dstate4_yr_1=dstate4*yr_1
g dstate5_yr_1=dstate5*yr_1
g dstate6_yr_1=dstate6*yr_1
g dstate7_yr_1=dstate7*yr_1
g dstate8_yr_1=dstate8*yr_1
g dstate9_yr_1=dstate9*yr_1
g dstate10_yr_1=dstate10*yr_1
g dstate11_yr_1=dstate11*yr_1
g dstate12_yr_1=dstate12*yr_1
g dstate13_yr_1=dstate13*yr_1
g dstate14_yr_1=dstate14*yr_1
g dstate15_yr_1=dstate15*yr_1
g dstate16_yr_1=dstate16*yr_1
g dstate17_yr_1=dstate17*yr_1
g dstate18_yr_1=dstate18*yr_1
g dstate19_yr_1=dstate19*yr_1
g dstate20_yr_1=dstate20*yr_1
g dstate21_yr_1=dstate21*yr_1
g dstate22_yr_1=dstate22*yr_1
g dstate23_yr_1=dstate23*yr_1
g dstate24_yr_1=dstate24*yr_1
g dstate25_yr_1=dstate25*yr_1
g dstate26_yr_1=dstate26*yr_1
g dstate27_yr_1=dstate27*yr_1
g dstate28_yr_1=dstate28*yr_1
g dstate29_yr_1=dstate29*yr_1
g dstate30_yr_1=dstate30*yr_1
g dstate31_yr_1=dstate31*yr_1
g dstate32_yr_1=dstate32*yr_1
g dstate33_yr_1=dstate33*yr_1
g dstate34_yr_1=dstate34*yr_1
g dstate35_yr_1=dstate35*yr_1
g dstate36_yr_1=dstate36*yr_1
g dstate37_yr_1=dstate37*yr_1
g dstate38_yr_1=dstate38*yr_1
g dstate39_yr_1=dstate39*yr_1
g dstate40_yr_1=dstate40*yr_1
g dstate41_yr_1=dstate41*yr_1
g dstate42_yr_1=dstate42*yr_1
g dstate43_yr_1=dstate43*yr_1
g dstate44_yr_1=dstate44*yr_1
g dstate45_yr_1=dstate45*yr_1
g dstate46_yr_1=dstate46*yr_1
g dstate47_yr_1=dstate47*yr_1
g dstate48_yr_1=dstate48*yr_1
g dstate49_yr_1=dstate49*yr_1
g dstate50_yr_1=dstate50*yr_1
g dstate1_yr_2=dstate1*yr_2
g dstate2_yr_2=dstate2*yr_2
g dstate3_yr_2=dstate3*yr_2
g dstate4_yr_2=dstate4*yr_2
g dstate5_yr_2=dstate5*yr_2
g dstate6_yr_2=dstate6*yr_2
g dstate7_yr_2=dstate7*yr_2
g dstate8_yr_2=dstate8*yr_2
g dstate9_yr_2=dstate9*yr_2
g dstate10_yr_2=dstate10*yr_2
g dstate11_yr_2=dstate11*yr_2
g dstate12_yr_2=dstate12*yr_2
g dstate13_yr_2=dstate13*yr_2
g dstate14_yr_2=dstate14*yr_2
g dstate15_yr_2=dstate15*yr_2
g dstate16_yr_2=dstate16*yr_2
g dstate17_yr_2=dstate17*yr_2
g dstate18_yr_2=dstate18*yr_2
g dstate19_yr_2=dstate19*yr_2
g dstate20_yr_2=dstate20*yr_2
g dstate21_yr_2=dstate21*yr_2
g dstate22_yr_2=dstate22*yr_2
g dstate23_yr_2=dstate23*yr_2
g dstate24_yr_2=dstate24*yr_2
g dstate25_yr_2=dstate25*yr_2
g dstate26_yr_2=dstate26*yr_2
g dstate27_yr_2=dstate27*yr_2
g dstate28_yr_2=dstate28*yr_2
g dstate29_yr_2=dstate29*yr_2
g dstate30_yr_2=dstate30*yr_2
g dstate31_yr_2=dstate31*yr_2
g dstate32_yr_2=dstate32*yr_2
g dstate33_yr_2=dstate33*yr_2
g dstate34_yr_2=dstate34*yr_2
g dstate35_yr_2=dstate35*yr_2
g dstate36_yr_2=dstate36*yr_2
g dstate37_yr_2=dstate37*yr_2
g dstate38_yr_2=dstate38*yr_2
g dstate39_yr_2=dstate39*yr_2
g dstate40_yr_2=dstate40*yr_2
g dstate41_yr_2=dstate41*yr_2
g dstate42_yr_2=dstate42*yr_2
g dstate43_yr_2=dstate43*yr_2
g dstate44_yr_2=dstate44*yr_2
g dstate45_yr_2=dstate45*yr_2
g dstate46_yr_2=dstate46*yr_2
g dstate47_yr_2=dstate47*yr_2
g dstate48_yr_2=dstate48*yr_2
g dstate49_yr_2=dstate49*yr_2
g dstate50_yr_2=dstate50*yr_2
g dstate1_yr_3=dstate1*yr_3
g dstate2_yr_3=dstate2*yr_3
g dstate3_yr_3=dstate3*yr_3
g dstate4_yr_3=dstate4*yr_3
g dstate5_yr_3=dstate5*yr_3
g dstate6_yr_3=dstate6*yr_3
g dstate7_yr_3=dstate7*yr_3
g dstate8_yr_3=dstate8*yr_3
g dstate9_yr_3=dstate9*yr_3
g dstate10_yr_3=dstate10*yr_3
g dstate11_yr_3=dstate11*yr_3
g dstate12_yr_3=dstate12*yr_3
g dstate13_yr_3=dstate13*yr_3
g dstate14_yr_3=dstate14*yr_3
g dstate15_yr_3=dstate15*yr_3
g dstate16_yr_3=dstate16*yr_3
g dstate17_yr_3=dstate17*yr_3
g dstate18_yr_3=dstate18*yr_3
g dstate19_yr_3=dstate19*yr_3
g dstate20_yr_3=dstate20*yr_3
g dstate21_yr_3=dstate21*yr_3
g dstate22_yr_3=dstate22*yr_3
g dstate23_yr_3=dstate23*yr_3
g dstate24_yr_3=dstate24*yr_3
g dstate25_yr_3=dstate25*yr_3
g dstate26_yr_3=dstate26*yr_3
g dstate27_yr_3=dstate27*yr_3
g dstate28_yr_3=dstate28*yr_3
g dstate29_yr_3=dstate29*yr_3
g dstate30_yr_3=dstate30*yr_3
g dstate31_yr_3=dstate31*yr_3
g dstate32_yr_3=dstate32*yr_3
g dstate33_yr_3=dstate33*yr_3
g dstate34_yr_3=dstate34*yr_3
g dstate35_yr_3=dstate35*yr_3
g dstate36_yr_3=dstate36*yr_3
g dstate37_yr_3=dstate37*yr_3
g dstate38_yr_3=dstate38*yr_3
g dstate39_yr_3=dstate39*yr_3
g dstate40_yr_3=dstate40*yr_3
g dstate41_yr_3=dstate41*yr_3
g dstate42_yr_3=dstate42*yr_3
g dstate43_yr_3=dstate43*yr_3
g dstate44_yr_3=dstate44*yr_3
g dstate45_yr_3=dstate45*yr_3
g dstate46_yr_3=dstate46*yr_3
g dstate47_yr_3=dstate47*yr_3
g dstate48_yr_3=dstate48*yr_3
g dstate49_yr_3=dstate49*yr_3
g dstate50_yr_3=dstate50*yr_3
g dstate1_yr_4=dstate1*yr_4
g dstate2_yr_4=dstate2*yr_4
g dstate3_yr_4=dstate3*yr_4
g dstate4_yr_4=dstate4*yr_4
g dstate5_yr_4=dstate5*yr_4
g dstate6_yr_4=dstate6*yr_4
g dstate7_yr_4=dstate7*yr_4
g dstate8_yr_4=dstate8*yr_4
g dstate9_yr_4=dstate9*yr_4
g dstate10_yr_4=dstate10*yr_4
g dstate11_yr_4=dstate11*yr_4
g dstate12_yr_4=dstate12*yr_4
g dstate13_yr_4=dstate13*yr_4
g dstate14_yr_4=dstate14*yr_4
g dstate15_yr_4=dstate15*yr_4
g dstate16_yr_4=dstate16*yr_4
g dstate17_yr_4=dstate17*yr_4
g dstate18_yr_4=dstate18*yr_4
g dstate19_yr_4=dstate19*yr_4
g dstate20_yr_4=dstate20*yr_4
g dstate21_yr_4=dstate21*yr_4
g dstate22_yr_4=dstate22*yr_4
g dstate23_yr_4=dstate23*yr_4
g dstate24_yr_4=dstate24*yr_4
g dstate25_yr_4=dstate25*yr_4
g dstate26_yr_4=dstate26*yr_4
g dstate27_yr_4=dstate27*yr_4
g dstate28_yr_4=dstate28*yr_4
g dstate29_yr_4=dstate29*yr_4
g dstate30_yr_4=dstate30*yr_4
g dstate31_yr_4=dstate31*yr_4
g dstate32_yr_4=dstate32*yr_4
g dstate33_yr_4=dstate33*yr_4
g dstate34_yr_4=dstate34*yr_4
g dstate35_yr_4=dstate35*yr_4
g dstate36_yr_4=dstate36*yr_4
g dstate37_yr_4=dstate37*yr_4
g dstate38_yr_4=dstate38*yr_4
g dstate39_yr_4=dstate39*yr_4
g dstate40_yr_4=dstate40*yr_4
g dstate41_yr_4=dstate41*yr_4
g dstate42_yr_4=dstate42*yr_4
g dstate43_yr_4=dstate43*yr_4
g dstate44_yr_4=dstate44*yr_4
g dstate45_yr_4=dstate45*yr_4
g dstate46_yr_4=dstate46*yr_4
g dstate47_yr_4=dstate47*yr_4
g dstate48_yr_4=dstate48*yr_4
g dstate49_yr_4=dstate49*yr_4
g dstate50_yr_4=dstate50*yr_4
g dstate1_yr_5=dstate1*yr_5
g dstate2_yr_5=dstate2*yr_5
g dstate3_yr_5=dstate3*yr_5
g dstate4_yr_5=dstate4*yr_5
g dstate5_yr_5=dstate5*yr_5
g dstate6_yr_5=dstate6*yr_5
g dstate7_yr_5=dstate7*yr_5
g dstate8_yr_5=dstate8*yr_5
g dstate9_yr_5=dstate9*yr_5
g dstate10_yr_5=dstate10*yr_5
g dstate11_yr_5=dstate11*yr_5
g dstate12_yr_5=dstate12*yr_5
g dstate13_yr_5=dstate13*yr_5
g dstate14_yr_5=dstate14*yr_5
g dstate15_yr_5=dstate15*yr_5
g dstate16_yr_5=dstate16*yr_5
g dstate17_yr_5=dstate17*yr_5
g dstate18_yr_5=dstate18*yr_5
g dstate19_yr_5=dstate19*yr_5
g dstate20_yr_5=dstate20*yr_5
g dstate21_yr_5=dstate21*yr_5
g dstate22_yr_5=dstate22*yr_5
g dstate23_yr_5=dstate23*yr_5
g dstate24_yr_5=dstate24*yr_5
g dstate25_yr_5=dstate25*yr_5
g dstate26_yr_5=dstate26*yr_5
g dstate27_yr_5=dstate27*yr_5
g dstate28_yr_5=dstate28*yr_5
g dstate29_yr_5=dstate29*yr_5
g dstate30_yr_5=dstate30*yr_5
g dstate31_yr_5=dstate31*yr_5
g dstate32_yr_5=dstate32*yr_5
g dstate33_yr_5=dstate33*yr_5
g dstate34_yr_5=dstate34*yr_5
g dstate35_yr_5=dstate35*yr_5
g dstate36_yr_5=dstate36*yr_5
g dstate37_yr_5=dstate37*yr_5
g dstate38_yr_5=dstate38*yr_5
g dstate39_yr_5=dstate39*yr_5
g dstate40_yr_5=dstate40*yr_5
g dstate41_yr_5=dstate41*yr_5
g dstate42_yr_5=dstate42*yr_5
g dstate43_yr_5=dstate43*yr_5
g dstate44_yr_5=dstate44*yr_5
g dstate45_yr_5=dstate45*yr_5
g dstate46_yr_5=dstate46*yr_5
g dstate47_yr_5=dstate47*yr_5
g dstate48_yr_5=dstate48*yr_5
g dstate49_yr_5=dstate49*yr_5
g dstate50_yr_5=dstate50*yr_5
}

replace fatal=fatalrate_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry"

reg dwage $dxx docc1-docc9 dsic2-dsic66 dstate1_yr_1-dstate50_yr_5 yr_2-yr_5  if pct_chng>-75 & pct_chng<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf



/* 3-year fatality models (B) */

replace fatal=fatalrate3b_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry"

reg dwage $dxx dstate1_yr_1-dstate50_yr_5 yr_2-yr_5  if pct_chng3b>-75 & pct_chng3b<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf


/* @@@ */
/* @@@ Robust9: adds controls for 1-digit occ by 2-digit ind @@@ */
/* @@@ */

quietly{
g dsic2_occ1=dsic2*occ1
g dsic3_occ1=dsic3*occ1
g dsic4_occ1=dsic4*occ1
g dsic5_occ1=dsic5*occ1
g dsic6_occ1=dsic6*occ1
g dsic7_occ1=dsic7*occ1
g dsic8_occ1=dsic8*occ1
g dsic9_occ1=dsic9*occ1
g dsic10_occ1=dsic10*occ1
g dsic11_occ1=dsic11*occ1
g dsic12_occ1=dsic12*occ1
g dsic13_occ1=dsic13*occ1
g dsic14_occ1=dsic14*occ1
g dsic15_occ1=dsic15*occ1
g dsic16_occ1=dsic16*occ1
g dsic17_occ1=dsic17*occ1
g dsic18_occ1=dsic18*occ1
g dsic19_occ1=dsic19*occ1
g dsic20_occ1=dsic20*occ1
g dsic21_occ1=dsic21*occ1
g dsic22_occ1=dsic22*occ1
g dsic23_occ1=dsic23*occ1
g dsic24_occ1=dsic24*occ1
g dsic25_occ1=dsic25*occ1
g dsic26_occ1=dsic26*occ1
g dsic27_occ1=dsic27*occ1
g dsic28_occ1=dsic28*occ1
g dsic29_occ1=dsic29*occ1
g dsic30_occ1=dsic30*occ1
g dsic31_occ1=dsic31*occ1
g dsic32_occ1=dsic32*occ1
g dsic33_occ1=dsic33*occ1
g dsic34_occ1=dsic34*occ1
g dsic35_occ1=dsic35*occ1
g dsic36_occ1=dsic36*occ1
g dsic37_occ1=dsic37*occ1
g dsic38_occ1=dsic38*occ1
g dsic39_occ1=dsic39*occ1
g dsic40_occ1=dsic40*occ1
g dsic41_occ1=dsic41*occ1
g dsic42_occ1=dsic42*occ1
g dsic43_occ1=dsic43*occ1
g dsic44_occ1=dsic44*occ1
g dsic45_occ1=dsic45*occ1
g dsic46_occ1=dsic46*occ1
g dsic47_occ1=dsic47*occ1
g dsic48_occ1=dsic48*occ1
g dsic49_occ1=dsic49*occ1
g dsic50_occ1=dsic50*occ1
g dsic51_occ1=dsic51*occ1
g dsic52_occ1=dsic52*occ1
g dsic53_occ1=dsic53*occ1
g dsic54_occ1=dsic54*occ1
g dsic55_occ1=dsic55*occ1
g dsic56_occ1=dsic56*occ1
g dsic57_occ1=dsic57*occ1
g dsic58_occ1=dsic58*occ1
g dsic59_occ1=dsic59*occ1
g dsic60_occ1=dsic60*occ1
g dsic61_occ1=dsic61*occ1
g dsic62_occ1=dsic62*occ1
g dsic63_occ1=dsic63*occ1
g dsic64_occ1=dsic64*occ1
g dsic65_occ1=dsic65*occ1
g dsic66_occ1=dsic66*occ1
g dsic2_occ2=dsic2*occ2
g dsic3_occ2=dsic3*occ2
g dsic4_occ2=dsic4*occ2
g dsic5_occ2=dsic5*occ2
g dsic6_occ2=dsic6*occ2
g dsic7_occ2=dsic7*occ2
g dsic8_occ2=dsic8*occ2
g dsic9_occ2=dsic9*occ2
g dsic10_occ2=dsic10*occ2
g dsic11_occ2=dsic11*occ2
g dsic12_occ2=dsic12*occ2
g dsic13_occ2=dsic13*occ2
g dsic14_occ2=dsic14*occ2
g dsic15_occ2=dsic15*occ2
g dsic16_occ2=dsic16*occ2
g dsic17_occ2=dsic17*occ2
g dsic18_occ2=dsic18*occ2
g dsic19_occ2=dsic19*occ2
g dsic20_occ2=dsic20*occ2
g dsic21_occ2=dsic21*occ2
g dsic22_occ2=dsic22*occ2
g dsic23_occ2=dsic23*occ2
g dsic24_occ2=dsic24*occ2
g dsic25_occ2=dsic25*occ2
g dsic26_occ2=dsic26*occ2
g dsic27_occ2=dsic27*occ2
g dsic28_occ2=dsic28*occ2
g dsic29_occ2=dsic29*occ2
g dsic30_occ2=dsic30*occ2
g dsic31_occ2=dsic31*occ2
g dsic32_occ2=dsic32*occ2
g dsic33_occ2=dsic33*occ2
g dsic34_occ2=dsic34*occ2
g dsic35_occ2=dsic35*occ2
g dsic36_occ2=dsic36*occ2
g dsic37_occ2=dsic37*occ2
g dsic38_occ2=dsic38*occ2
g dsic39_occ2=dsic39*occ2
g dsic40_occ2=dsic40*occ2
g dsic41_occ2=dsic41*occ2
g dsic42_occ2=dsic42*occ2
g dsic43_occ2=dsic43*occ2
g dsic44_occ2=dsic44*occ2
g dsic45_occ2=dsic45*occ2
g dsic46_occ2=dsic46*occ2
g dsic47_occ2=dsic47*occ2
g dsic48_occ2=dsic48*occ2
g dsic49_occ2=dsic49*occ2
g dsic50_occ2=dsic50*occ2
g dsic51_occ2=dsic51*occ2
g dsic52_occ2=dsic52*occ2
g dsic53_occ2=dsic53*occ2
g dsic54_occ2=dsic54*occ2
g dsic55_occ2=dsic55*occ2
g dsic56_occ2=dsic56*occ2
g dsic57_occ2=dsic57*occ2
g dsic58_occ2=dsic58*occ2
g dsic59_occ2=dsic59*occ2
g dsic60_occ2=dsic60*occ2
g dsic61_occ2=dsic61*occ2
g dsic62_occ2=dsic62*occ2
g dsic63_occ2=dsic63*occ2
g dsic64_occ2=dsic64*occ2
g dsic65_occ2=dsic65*occ2
g dsic66_occ2=dsic66*occ2
g dsic2_occ3=dsic2*occ3
g dsic3_occ3=dsic3*occ3
g dsic4_occ3=dsic4*occ3
g dsic5_occ3=dsic5*occ3
g dsic6_occ3=dsic6*occ3
g dsic7_occ3=dsic7*occ3
g dsic8_occ3=dsic8*occ3
g dsic9_occ3=dsic9*occ3
g dsic10_occ3=dsic10*occ3
g dsic11_occ3=dsic11*occ3
g dsic12_occ3=dsic12*occ3
g dsic13_occ3=dsic13*occ3
g dsic14_occ3=dsic14*occ3
g dsic15_occ3=dsic15*occ3
g dsic16_occ3=dsic16*occ3
g dsic17_occ3=dsic17*occ3
g dsic18_occ3=dsic18*occ3
g dsic19_occ3=dsic19*occ3
g dsic20_occ3=dsic20*occ3
g dsic21_occ3=dsic21*occ3
g dsic22_occ3=dsic22*occ3
g dsic23_occ3=dsic23*occ3
g dsic24_occ3=dsic24*occ3
g dsic25_occ3=dsic25*occ3
g dsic26_occ3=dsic26*occ3
g dsic27_occ3=dsic27*occ3
g dsic28_occ3=dsic28*occ3
g dsic29_occ3=dsic29*occ3
g dsic30_occ3=dsic30*occ3
g dsic31_occ3=dsic31*occ3
g dsic32_occ3=dsic32*occ3
g dsic33_occ3=dsic33*occ3
g dsic34_occ3=dsic34*occ3
g dsic35_occ3=dsic35*occ3
g dsic36_occ3=dsic36*occ3
g dsic37_occ3=dsic37*occ3
g dsic38_occ3=dsic38*occ3
g dsic39_occ3=dsic39*occ3
g dsic40_occ3=dsic40*occ3
g dsic41_occ3=dsic41*occ3
g dsic42_occ3=dsic42*occ3
g dsic43_occ3=dsic43*occ3
g dsic44_occ3=dsic44*occ3
g dsic45_occ3=dsic45*occ3
g dsic46_occ3=dsic46*occ3
g dsic47_occ3=dsic47*occ3
g dsic48_occ3=dsic48*occ3
g dsic49_occ3=dsic49*occ3
g dsic50_occ3=dsic50*occ3
g dsic51_occ3=dsic51*occ3
g dsic52_occ3=dsic52*occ3
g dsic53_occ3=dsic53*occ3
g dsic54_occ3=dsic54*occ3
g dsic55_occ3=dsic55*occ3
g dsic56_occ3=dsic56*occ3
g dsic57_occ3=dsic57*occ3
g dsic58_occ3=dsic58*occ3
g dsic59_occ3=dsic59*occ3
g dsic60_occ3=dsic60*occ3
g dsic61_occ3=dsic61*occ3
g dsic62_occ3=dsic62*occ3
g dsic63_occ3=dsic63*occ3
g dsic64_occ3=dsic64*occ3
g dsic65_occ3=dsic65*occ3
g dsic66_occ3=dsic66*occ3
g dsic2_occ4=dsic2*occ4
g dsic3_occ4=dsic3*occ4
g dsic4_occ4=dsic4*occ4
g dsic5_occ4=dsic5*occ4
g dsic6_occ4=dsic6*occ4
g dsic7_occ4=dsic7*occ4
g dsic8_occ4=dsic8*occ4
g dsic9_occ4=dsic9*occ4
g dsic10_occ4=dsic10*occ4
g dsic11_occ4=dsic11*occ4
g dsic12_occ4=dsic12*occ4
g dsic13_occ4=dsic13*occ4
g dsic14_occ4=dsic14*occ4
g dsic15_occ4=dsic15*occ4
g dsic16_occ4=dsic16*occ4
g dsic17_occ4=dsic17*occ4
g dsic18_occ4=dsic18*occ4
g dsic19_occ4=dsic19*occ4
g dsic20_occ4=dsic20*occ4
g dsic21_occ4=dsic21*occ4
g dsic22_occ4=dsic22*occ4
g dsic23_occ4=dsic23*occ4
g dsic24_occ4=dsic24*occ4
g dsic25_occ4=dsic25*occ4
g dsic26_occ4=dsic26*occ4
g dsic27_occ4=dsic27*occ4
g dsic28_occ4=dsic28*occ4
g dsic29_occ4=dsic29*occ4
g dsic30_occ4=dsic30*occ4
g dsic31_occ4=dsic31*occ4
g dsic32_occ4=dsic32*occ4
g dsic33_occ4=dsic33*occ4
g dsic34_occ4=dsic34*occ4
g dsic35_occ4=dsic35*occ4
g dsic36_occ4=dsic36*occ4
g dsic37_occ4=dsic37*occ4
g dsic38_occ4=dsic38*occ4
g dsic39_occ4=dsic39*occ4
g dsic40_occ4=dsic40*occ4
g dsic41_occ4=dsic41*occ4
g dsic42_occ4=dsic42*occ4
g dsic43_occ4=dsic43*occ4
g dsic44_occ4=dsic44*occ4
g dsic45_occ4=dsic45*occ4
g dsic46_occ4=dsic46*occ4
g dsic47_occ4=dsic47*occ4
g dsic48_occ4=dsic48*occ4
g dsic49_occ4=dsic49*occ4
g dsic50_occ4=dsic50*occ4
g dsic51_occ4=dsic51*occ4
g dsic52_occ4=dsic52*occ4
g dsic53_occ4=dsic53*occ4
g dsic54_occ4=dsic54*occ4
g dsic55_occ4=dsic55*occ4
g dsic56_occ4=dsic56*occ4
g dsic57_occ4=dsic57*occ4
g dsic58_occ4=dsic58*occ4
g dsic59_occ4=dsic59*occ4
g dsic60_occ4=dsic60*occ4
g dsic61_occ4=dsic61*occ4
g dsic62_occ4=dsic62*occ4
g dsic63_occ4=dsic63*occ4
g dsic64_occ4=dsic64*occ4
g dsic65_occ4=dsic65*occ4
g dsic66_occ4=dsic66*occ4
g dsic2_occ5=dsic2*occ5
g dsic3_occ5=dsic3*occ5
g dsic4_occ5=dsic4*occ5
g dsic5_occ5=dsic5*occ5
g dsic6_occ5=dsic6*occ5
g dsic7_occ5=dsic7*occ5
g dsic8_occ5=dsic8*occ5
g dsic9_occ5=dsic9*occ5
g dsic10_occ5=dsic10*occ5
g dsic11_occ5=dsic11*occ5
g dsic12_occ5=dsic12*occ5
g dsic13_occ5=dsic13*occ5
g dsic14_occ5=dsic14*occ5
g dsic15_occ5=dsic15*occ5
g dsic16_occ5=dsic16*occ5
g dsic17_occ5=dsic17*occ5
g dsic18_occ5=dsic18*occ5
g dsic19_occ5=dsic19*occ5
g dsic20_occ5=dsic20*occ5
g dsic21_occ5=dsic21*occ5
g dsic22_occ5=dsic22*occ5
g dsic23_occ5=dsic23*occ5
g dsic24_occ5=dsic24*occ5
g dsic25_occ5=dsic25*occ5
g dsic26_occ5=dsic26*occ5
g dsic27_occ5=dsic27*occ5
g dsic28_occ5=dsic28*occ5
g dsic29_occ5=dsic29*occ5
g dsic30_occ5=dsic30*occ5
g dsic31_occ5=dsic31*occ5
g dsic32_occ5=dsic32*occ5
g dsic33_occ5=dsic33*occ5
g dsic34_occ5=dsic34*occ5
g dsic35_occ5=dsic35*occ5
g dsic36_occ5=dsic36*occ5
g dsic37_occ5=dsic37*occ5
g dsic38_occ5=dsic38*occ5
g dsic39_occ5=dsic39*occ5
g dsic40_occ5=dsic40*occ5
g dsic41_occ5=dsic41*occ5
g dsic42_occ5=dsic42*occ5
g dsic43_occ5=dsic43*occ5
g dsic44_occ5=dsic44*occ5
g dsic45_occ5=dsic45*occ5
g dsic46_occ5=dsic46*occ5
g dsic47_occ5=dsic47*occ5
g dsic48_occ5=dsic48*occ5
g dsic49_occ5=dsic49*occ5
g dsic50_occ5=dsic50*occ5
g dsic51_occ5=dsic51*occ5
g dsic52_occ5=dsic52*occ5
g dsic53_occ5=dsic53*occ5
g dsic54_occ5=dsic54*occ5
g dsic55_occ5=dsic55*occ5
g dsic56_occ5=dsic56*occ5
g dsic57_occ5=dsic57*occ5
g dsic58_occ5=dsic58*occ5
g dsic59_occ5=dsic59*occ5
g dsic60_occ5=dsic60*occ5
g dsic61_occ5=dsic61*occ5
g dsic62_occ5=dsic62*occ5
g dsic63_occ5=dsic63*occ5
g dsic64_occ5=dsic64*occ5
g dsic65_occ5=dsic65*occ5
g dsic66_occ5=dsic66*occ5
g dsic2_occ6=dsic2*occ6
g dsic3_occ6=dsic3*occ6
g dsic4_occ6=dsic4*occ6
g dsic5_occ6=dsic5*occ6
g dsic6_occ6=dsic6*occ6
g dsic7_occ6=dsic7*occ6
g dsic8_occ6=dsic8*occ6
g dsic9_occ6=dsic9*occ6
g dsic10_occ6=dsic10*occ6
g dsic11_occ6=dsic11*occ6
g dsic12_occ6=dsic12*occ6
g dsic13_occ6=dsic13*occ6
g dsic14_occ6=dsic14*occ6
g dsic15_occ6=dsic15*occ6
g dsic16_occ6=dsic16*occ6
g dsic17_occ6=dsic17*occ6
g dsic18_occ6=dsic18*occ6
g dsic19_occ6=dsic19*occ6
g dsic20_occ6=dsic20*occ6
g dsic21_occ6=dsic21*occ6
g dsic22_occ6=dsic22*occ6
g dsic23_occ6=dsic23*occ6
g dsic24_occ6=dsic24*occ6
g dsic25_occ6=dsic25*occ6
g dsic26_occ6=dsic26*occ6
g dsic27_occ6=dsic27*occ6
g dsic28_occ6=dsic28*occ6
g dsic29_occ6=dsic29*occ6
g dsic30_occ6=dsic30*occ6
g dsic31_occ6=dsic31*occ6
g dsic32_occ6=dsic32*occ6
g dsic33_occ6=dsic33*occ6
g dsic34_occ6=dsic34*occ6
g dsic35_occ6=dsic35*occ6
g dsic36_occ6=dsic36*occ6
g dsic37_occ6=dsic37*occ6
g dsic38_occ6=dsic38*occ6
g dsic39_occ6=dsic39*occ6
g dsic40_occ6=dsic40*occ6
g dsic41_occ6=dsic41*occ6
g dsic42_occ6=dsic42*occ6
g dsic43_occ6=dsic43*occ6
g dsic44_occ6=dsic44*occ6
g dsic45_occ6=dsic45*occ6
g dsic46_occ6=dsic46*occ6
g dsic47_occ6=dsic47*occ6
g dsic48_occ6=dsic48*occ6
g dsic49_occ6=dsic49*occ6
g dsic50_occ6=dsic50*occ6
g dsic51_occ6=dsic51*occ6
g dsic52_occ6=dsic52*occ6
g dsic53_occ6=dsic53*occ6
g dsic54_occ6=dsic54*occ6
g dsic55_occ6=dsic55*occ6
g dsic56_occ6=dsic56*occ6
g dsic57_occ6=dsic57*occ6
g dsic58_occ6=dsic58*occ6
g dsic59_occ6=dsic59*occ6
g dsic60_occ6=dsic60*occ6
g dsic61_occ6=dsic61*occ6
g dsic62_occ6=dsic62*occ6
g dsic63_occ6=dsic63*occ6
g dsic64_occ6=dsic64*occ6
g dsic65_occ6=dsic65*occ6
g dsic66_occ6=dsic66*occ6
g dsic2_occ7=dsic2*occ7
g dsic3_occ7=dsic3*occ7
g dsic4_occ7=dsic4*occ7
g dsic5_occ7=dsic5*occ7
g dsic6_occ7=dsic6*occ7
g dsic7_occ7=dsic7*occ7
g dsic8_occ7=dsic8*occ7
g dsic9_occ7=dsic9*occ7
g dsic10_occ7=dsic10*occ7
g dsic11_occ7=dsic11*occ7
g dsic12_occ7=dsic12*occ7
g dsic13_occ7=dsic13*occ7
g dsic14_occ7=dsic14*occ7
g dsic15_occ7=dsic15*occ7
g dsic16_occ7=dsic16*occ7
g dsic17_occ7=dsic17*occ7
g dsic18_occ7=dsic18*occ7
g dsic19_occ7=dsic19*occ7
g dsic20_occ7=dsic20*occ7
g dsic21_occ7=dsic21*occ7
g dsic22_occ7=dsic22*occ7
g dsic23_occ7=dsic23*occ7
g dsic24_occ7=dsic24*occ7
g dsic25_occ7=dsic25*occ7
g dsic26_occ7=dsic26*occ7
g dsic27_occ7=dsic27*occ7
g dsic28_occ7=dsic28*occ7
g dsic29_occ7=dsic29*occ7
g dsic30_occ7=dsic30*occ7
g dsic31_occ7=dsic31*occ7
g dsic32_occ7=dsic32*occ7
g dsic33_occ7=dsic33*occ7
g dsic34_occ7=dsic34*occ7
g dsic35_occ7=dsic35*occ7
g dsic36_occ7=dsic36*occ7
g dsic37_occ7=dsic37*occ7
g dsic38_occ7=dsic38*occ7
g dsic39_occ7=dsic39*occ7
g dsic40_occ7=dsic40*occ7
g dsic41_occ7=dsic41*occ7
g dsic42_occ7=dsic42*occ7
g dsic43_occ7=dsic43*occ7
g dsic44_occ7=dsic44*occ7
g dsic45_occ7=dsic45*occ7
g dsic46_occ7=dsic46*occ7
g dsic47_occ7=dsic47*occ7
g dsic48_occ7=dsic48*occ7
g dsic49_occ7=dsic49*occ7
g dsic50_occ7=dsic50*occ7
g dsic51_occ7=dsic51*occ7
g dsic52_occ7=dsic52*occ7
g dsic53_occ7=dsic53*occ7
g dsic54_occ7=dsic54*occ7
g dsic55_occ7=dsic55*occ7
g dsic56_occ7=dsic56*occ7
g dsic57_occ7=dsic57*occ7
g dsic58_occ7=dsic58*occ7
g dsic59_occ7=dsic59*occ7
g dsic60_occ7=dsic60*occ7
g dsic61_occ7=dsic61*occ7
g dsic62_occ7=dsic62*occ7
g dsic63_occ7=dsic63*occ7
g dsic64_occ7=dsic64*occ7
g dsic65_occ7=dsic65*occ7
g dsic66_occ7=dsic66*occ7
g dsic2_occ8=dsic2*occ8
g dsic3_occ8=dsic3*occ8
g dsic4_occ8=dsic4*occ8
g dsic5_occ8=dsic5*occ8
g dsic6_occ8=dsic6*occ8
g dsic7_occ8=dsic7*occ8
g dsic8_occ8=dsic8*occ8
g dsic9_occ8=dsic9*occ8
g dsic10_occ8=dsic10*occ8
g dsic11_occ8=dsic11*occ8
g dsic12_occ8=dsic12*occ8
g dsic13_occ8=dsic13*occ8
g dsic14_occ8=dsic14*occ8
g dsic15_occ8=dsic15*occ8
g dsic16_occ8=dsic16*occ8
g dsic17_occ8=dsic17*occ8
g dsic18_occ8=dsic18*occ8
g dsic19_occ8=dsic19*occ8
g dsic20_occ8=dsic20*occ8
g dsic21_occ8=dsic21*occ8
g dsic22_occ8=dsic22*occ8
g dsic23_occ8=dsic23*occ8
g dsic24_occ8=dsic24*occ8
g dsic25_occ8=dsic25*occ8
g dsic26_occ8=dsic26*occ8
g dsic27_occ8=dsic27*occ8
g dsic28_occ8=dsic28*occ8
g dsic29_occ8=dsic29*occ8
g dsic30_occ8=dsic30*occ8
g dsic31_occ8=dsic31*occ8
g dsic32_occ8=dsic32*occ8
g dsic33_occ8=dsic33*occ8
g dsic34_occ8=dsic34*occ8
g dsic35_occ8=dsic35*occ8
g dsic36_occ8=dsic36*occ8
g dsic37_occ8=dsic37*occ8
g dsic38_occ8=dsic38*occ8
g dsic39_occ8=dsic39*occ8
g dsic40_occ8=dsic40*occ8
g dsic41_occ8=dsic41*occ8
g dsic42_occ8=dsic42*occ8
g dsic43_occ8=dsic43*occ8
g dsic44_occ8=dsic44*occ8
g dsic45_occ8=dsic45*occ8
g dsic46_occ8=dsic46*occ8
g dsic47_occ8=dsic47*occ8
g dsic48_occ8=dsic48*occ8
g dsic49_occ8=dsic49*occ8
g dsic50_occ8=dsic50*occ8
g dsic51_occ8=dsic51*occ8
g dsic52_occ8=dsic52*occ8
g dsic53_occ8=dsic53*occ8
g dsic54_occ8=dsic54*occ8
g dsic55_occ8=dsic55*occ8
g dsic56_occ8=dsic56*occ8
g dsic57_occ8=dsic57*occ8
g dsic58_occ8=dsic58*occ8
g dsic59_occ8=dsic59*occ8
g dsic60_occ8=dsic60*occ8
g dsic61_occ8=dsic61*occ8
g dsic62_occ8=dsic62*occ8
g dsic63_occ8=dsic63*occ8
g dsic64_occ8=dsic64*occ8
g dsic65_occ8=dsic65*occ8
g dsic66_occ8=dsic66*occ8
g dsic2_occ9=dsic2*occ9
g dsic3_occ9=dsic3*occ9
g dsic4_occ9=dsic4*occ9
g dsic5_occ9=dsic5*occ9
g dsic6_occ9=dsic6*occ9
g dsic7_occ9=dsic7*occ9
g dsic8_occ9=dsic8*occ9
g dsic9_occ9=dsic9*occ9
g dsic10_occ9=dsic10*occ9
g dsic11_occ9=dsic11*occ9
g dsic12_occ9=dsic12*occ9
g dsic13_occ9=dsic13*occ9
g dsic14_occ9=dsic14*occ9
g dsic15_occ9=dsic15*occ9
g dsic16_occ9=dsic16*occ9
g dsic17_occ9=dsic17*occ9
g dsic18_occ9=dsic18*occ9
g dsic19_occ9=dsic19*occ9
g dsic20_occ9=dsic20*occ9
g dsic21_occ9=dsic21*occ9
g dsic22_occ9=dsic22*occ9
g dsic23_occ9=dsic23*occ9
g dsic24_occ9=dsic24*occ9
g dsic25_occ9=dsic25*occ9
g dsic26_occ9=dsic26*occ9
g dsic27_occ9=dsic27*occ9
g dsic28_occ9=dsic28*occ9
g dsic29_occ9=dsic29*occ9
g dsic30_occ9=dsic30*occ9
g dsic31_occ9=dsic31*occ9
g dsic32_occ9=dsic32*occ9
g dsic33_occ9=dsic33*occ9
g dsic34_occ9=dsic34*occ9
g dsic35_occ9=dsic35*occ9
g dsic36_occ9=dsic36*occ9
g dsic37_occ9=dsic37*occ9
g dsic38_occ9=dsic38*occ9
g dsic39_occ9=dsic39*occ9
g dsic40_occ9=dsic40*occ9
g dsic41_occ9=dsic41*occ9
g dsic42_occ9=dsic42*occ9
g dsic43_occ9=dsic43*occ9
g dsic44_occ9=dsic44*occ9
g dsic45_occ9=dsic45*occ9
g dsic46_occ9=dsic46*occ9
g dsic47_occ9=dsic47*occ9
g dsic48_occ9=dsic48*occ9
g dsic49_occ9=dsic49*occ9
g dsic50_occ9=dsic50*occ9
g dsic51_occ9=dsic51*occ9
g dsic52_occ9=dsic52*occ9
g dsic53_occ9=dsic53*occ9
g dsic54_occ9=dsic54*occ9
g dsic55_occ9=dsic55*occ9
g dsic56_occ9=dsic56*occ9
g dsic57_occ9=dsic57*occ9
g dsic58_occ9=dsic58*occ9
g dsic59_occ9=dsic59*occ9
g dsic60_occ9=dsic60*occ9
g dsic61_occ9=dsic61*occ9
g dsic62_occ9=dsic62*occ9
g dsic63_occ9=dsic63*occ9
g dsic64_occ9=dsic64*occ9
g dsic65_occ9=dsic65*occ9
g dsic66_occ9=dsic66*occ9
}


replace fatal=fatalrate_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry"

reg dwage $dxx dsic2_occ1-dsic66_occ9 yr_2-yr_5 dstate2-dstate50 if pct_chng>-75 & pct_chng<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */


g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf



/* 3-year fatality models (B) */

replace fatal=fatalrate3b_
replace dfatal=fatal-l2.fatal
global dxx="dfatal dage dage2 dcendiv2-dcendiv9 dunion dmarry"

reg dwage $dxx dsic2_occ1-dsic66_occ9 yr_2-yr_5 dstate2-dstate50 if pct_chng3b>-75 & pct_chng3b<300, noconstant robust cluster(indocc)

quietly{
g n=e(N)
matrix v=e(V)
matrix varf=el(v,1,1)
g var_fatal=trace(varf)
means rwage if e(sample)
gen mnwage=r(mean)
gen varwage=r(Var) 

sum mnwage varwage var_fatal

means ttl_work_hrs if e(sample)
g mnhrs=r(mean)
g varhrs=r(Var)
correlate rwage ttl_work_hrs, covariance
g cov_wghrs=r(cov_12)


}

/* Assume regressors are fixed constants in calculation of C.I. */

g ivl1=_b[dfatal]*mnwage*2000*100000
g var_ivl1=(2000^2)*(100000^2)*(mnwage^2*var_fatal)
g sd_ivl1=sqrt(var_ivl1)
g ci95lower=ivl1-1.96*(sd_ivl1)
g ci95upper=ivl1+1.96*(sd_ivl1)

g ivl1_alt=_b[dfatal]*mnwage*mnhrs*100000
g var_ivl1_alt = (100000^2)*( mnwage^2*mnhrs^2*var_fatal)
g sd_ivl1_alt=sqrt(var_ivl1_alt)
g ci95lower_alt=ivl1_alt-1.96*(sd_ivl1_alt)
g ci95upper_alt=ivl1_alt+1.96*(sd_ivl1_alt)

sum ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper  ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt if e(sample)

drop mnwage varwage mnhrs varhrs cov_wghrs var_fatal ivl1 var_ivl1 sd_ivl1 ci95lower ci95upper ivl1_alt var_ivl1_alt sd_ivl1_alt ci95lower_alt ci95upper_alt n
matrix drop v varf


log close
 


